#include <tsin/util/GFXTimer.hpp>

#include <tsin/config/Config.hpp>
#include <SDL/SDL_framerate.h>

using namespace tsin;

namespace tsin {
        static FPSmanager manager;
}

GFXTimer::GFXTimer()
{
        SDL_initFramerate(&manager);
}

GFXTimer::GFXTimer(Config &config)
{
        SDL_initFramerate(&manager);
        SDL_setFramerate(&manager, config.fps);
}

void GFXTimer::setFps(int fps)
{
        SDL_setFramerate(&manager, fps);
}

void GFXTimer::setInterval(int msec)
{
        SDL_setFramerate(&manager, 1000 / msec);
}

void GFXTimer::delay()
{
        SDL_framerateDelay(&manager);
}
